﻿@{
    ViewData["Title"] = new string[] { "广告位管理" };
    TempData["subMenu-check"] = new string[] { "Public", "ManageAdvertising" };
    IEnumerable<SelectListItem> sizeSelectList = ViewData.Get<IEnumerable<SelectListItem>>("sizeSelectList", null);
}
<div class="row tn-page-heading tn-mb-10">
    <div class="col-lg-12">
        <h3>广告位管理</h3>
    </div>
</div>
@Styles.Render("~/Bundle/Styles/fancyBox")

<div class="panel panel-default">
    <div class="panel-body ">
        <div class="form-inline tn-tool-column text-right row">
            <div class="form-group col-xs-3 text-left">
                <a class="btn btn-default edit-user layerposition" href="javascript:;"><i class="fa fa-plus"></i> 添加广告位</a>
            </div>
            <div class="form-group col-xs-8 text-right">
                @Html.DropDownList("sizeSelectList", sizeSelectList, new { @class = "form-control" })
            </div>
        </div>
    </div>
</div>
<div class="panel panel-default">
    <div id="_listPositions" class="panel-body">
        @Html.Action("_ListPositions", "ControlPanel")
    </div>
</div>


<script>
    require(['jquery', 'tnlayer', 'tnfancyBox'], function ($, tnlayer) {

        $('.layerposition').click(function () {
            tnlayer.layermodal('添加广告位', '@SiteUrls.Instance()._EditPosition(null)', '450px', 'auto')
        })

        $("#sizeSelectList").change(function () {
            var position = $("#sizeSelectList option:selected").val();
            var center = position.indexOf("*");
            var width = position.substring(0, center);
            var height = position.substring(center + 1, position.length)
            $.get("@CachedUrlHelper.Action("_ListPositions", "ControlPanel")", { width: width, height: height, requestTime: new Date().getTime() }, function (data) {
                if (data) {
                    $("#_listPositions").html(data);
                }
            })
        })
    })
</script>